<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="评估编号" prop="evaluateNo">
        <el-input
          v-model="queryParams.evaluateNo"
          placeholder="请输入评估编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评估机构" prop="evaluateAgency">
        <el-input
          v-model="queryParams.evaluateAgency"
          placeholder="请输入评估机构"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="评估时间" >
        <el-date-picker
          placeholder="请选择评估时间"
          v-model="daterangeTime"
          @change="changeDate"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="$emit('handleAdd')"
                   v-hasPermi="['sacw:evaluate:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
                   v-hasPermi="['sacw:evaluate:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="$emit('getList')"></right-toolbar>
    </el-row>
  </div>
</template>

<script>
import { addDateRange } from '@/utils/ruoyi'

export default {
  name: 'evaluateQuery',
  props:{
    queryParams:{
      type:Object,
      required:true
    }
  },
  data(){
    return{
      // 显示搜索条件
      showSearch: true,
      // 时间范围
      daterangeTime: [],
    }
  },
  methods:{
    changeDate(value){
      addDateRange(this.queryParams,value)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sacw/evaluate/export', {
        ...this.queryParams
      }, `evaluate${new Date().getTime()}.xlsx`)
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.$emit('getList')
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeTime = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
  }
}
</script>

<style scoped>

</style>
